package com.wc.fortnight_blue_bridge.Q241116.召唤帝皇侠;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/11/16 19:13
 * @description
 * https://www.lanqiao.cn/problems/20032/learning/?contest_id=223
 */
public class Main {
    /**
     * 思路：
     * 推公式
     * 1  4  9   16 ... n * n, 一定可以 (1)
     * i * i ~ (i + 1) * (i + 1), 之间一定要是 i的倍数
     * 找规律 i = 1, 5  5 + 9  5 + 9 + 14 ... (5 + 9 + 14 + .. + 4 * n + 1)
     * a[n] = 1 + 4 * n
     * S[n] = a[1] + a[2] + ... + a[n] = 3 * n + 2 * n * n
     * b[n] = S[n]
     * T[n] = b[1] + b[2] + ... + b[n] = (3 + 3 * n) * n / 2 + 2 * (n * (n + 1) * (2 * n + 1) / 6 (2)
     * bound = sqrt(x)
     * bound * bound + 1 ~ x  (3)
     * (3) 怎么球呢, 找到左边界 l = bound * bound + bound, r = x / bound * bound, 个数 (r - l) / bound + 1, 用前缀和公式
     * sum = (1) + (2) + (3)
     * sum = sumSq(bound) + T[bound - 1];
     */
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static long x, P = 998244353;

    public static void main(String[] args) {
        int T = sc.nextInt();
        while (T-- > 0){
            x = sc.nextLong();
            long bound = (long) Math.sqrt(x);
            long sum = (sumSq(bound) + sumBn(bound - 1)) % P;
            if (x > bound * bound) {
                long r = x / bound * bound;
                long l = bound * bound + bound;
                // (r + l) * ((r - l) / bound + 1)/ 2
                sum = sum + ((r + l) % P * (((r - l) % P) * qmi(bound, P - 2, P) % P + 1) % P) * qmi(2, P - 2, P) % P;
                sum %= P;
            }
            out.println(sum);
        }
        out.flush();
    }

    static long sumSq(long n){
        return n * (n + 1) % P * (2 * n + 1) % P * qmi(6, P - 2, P) % P;
    }

    static long sumBn(long n){
        return ((3 + 3 * n) * n % P * qmi(2, P - 2, P)  % P + 2 * sumSq(n) % P) % P;
    }

    static long qmi(long a, long b, long p){
        long res = 1;
        while (b > 0){
            if ((b & 1) == 1) res = res * a % p;
            a = a * a % p;
            b >>= 1;
        }
        return res;
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}

